package com.example.observer.v2;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        Child child = Child.getInstance();
        
        child.wakeUp();
    }
}

class Child {
    private boolean cry=false;
    private List<Obs> obsList=new ArrayList<>();
    {
        obsList.add(new Dad());
    }

    private static final Child child=new Child();

    private Child(){
    }

    public static Child getInstance(){
        return child;
    }



    public boolean isCry(){
        return cry;
    }

    public void wakeUp(){
        System.out.println("wuwuwuwu");
        child.cry=true;
        for (Obs obs : obsList) {
            obs.handle();
        }
    }
}

interface Obs{
    void handle();
}

class Dad implements Obs{
    @Override
    public void handle(){
        System.out.println("dad handle");
    }
}
